﻿#include "parser_test.h"

void parser_test::test_analyse_predicate_test1()
{
	cpplexer* lex =new cpplexer;
	lex->createBufferFromString("age(string,integer)\nCLAUSES");
	parser par(lex);
	QMap<QString,QVector<type>> pred_args;
	QVector<type> args_type;
	args_type<<String<<Integer;
	pred_args["age"] = args_type;
	bool exp_result = false;
	par.lex->next();
	bool result = par.analyse_predicate();
	QVERIFY2(result==exp_result,"returned values are not the same at test_analyse_predicate_test1");
	compare_vectors(args_type,par.predargstypes["age"],"test_analyse_predicate_test1");
	QVERIFY2(pred_args.operator== (par.predargstypes),"Keys of maps are not equal test_analyse_predicate_test1");
	
}

//Тест - предикат без аргументов
void parser_test::test_analyse_predicate_test2()
{
	cpplexer* lex =new cpplexer;
	//Вызывается для предиката close без аргументов
	lex->createBufferFromString("close\nCLAUSES");
	parser par(lex);
	QMap<QString, QVector<type> > pred_args;
	QVector<type> args_type;
	pred_args["close"] = args_type;
	bool exp_result = true;
	par.lex->next();
	bool result = par.analyse_predicate();
	QVERIFY2(result==exp_result,"returned values are not the same at test_analyse_predicate_test2");
	compare_vectors(args_type,par.predargstypes["close"],"test_analyse_predicate_test2");
	QVERIFY2(pred_args.operator==(par.predargstypes),"Keys of maps are not equal test_analyse_predicate_test2");
}

//Тест - предикат с одинаковыми типами 
void parser_test::test_analyse_predicate_test3()
{
	cpplexer* lex =new cpplexer;
	//Вызывается для предиката likes( string, string)
	lex->createBufferFromString("likes( string, string)\nCLAUSES");
	parser par(lex);
	QMap<QString, QVector<type> > pred_args;
	QVector<type> args_type;
	args_type<<String<<String;
	pred_args["likes"] = args_type;
	bool exp_result = false;
	par.lex->next();
	bool result = par.analyse_predicate();
	QVERIFY2(result==exp_result,"returned values are not the same at test_analyse_predicate_test3");
	compare_vectors(args_type,par.predargstypes["likes"],"test_analyse_predicate_test3");
	QVERIFY2(pred_args.operator==(par.predargstypes),"Keys of maps are not equal test_analyse_predicate_test3");
	
}

//Тест - предикат с символьным типом
void parser_test::test_analyse_predicate_test4()
{
	//cpplexer* lex =new cpplexer;
	////Вызывается для предиката my_predicate(symbol,integer)
	//lex->createBufferFromString("my_predicate(symbol,integer)");
	//parser par(lex);
	//QMap<QString, QVector<type> > pred_args;
	//QVector<type> args_type;
	//args_type<<Symbol<<Integer;
	//pred_args["my_predicate"] = args_type;
	//bool exp_result = false;
	//par.lex->next();
	//bool result = par.analyse_predicate();
	//QVERIFY2(result==exp_result,"returned values are not the same at test_analyse_predicate_test4");
	//compare_vectors(args_type,par.predargstypes["my_predicate"],"test_analyse_predicate_test4");
	//QVERIFY2(pred_args.operator==(par.predargstypes),"Keys of maps are not equal test_analyse_predicate_test4");
	//
}

//Тест - предикат с символьным типом
void parser_test::test_analyse_predicate_test5()
{
	cpplexer* lex =new cpplexer;
	//Вызывается для предиката car(make, mileage,years_on_road,color,cost) - все возможные типы переменных
	lex->createBufferFromString("car(string, integer,integer,char,real)\nCLAUSES");
	QMap<QString, QVector<type> > pred_args;
	QVector<type> args_type;
	parser par(lex);
	args_type<<String<<Integer<<Integer<<Char<<Real;
	pred_args["car"] = args_type;
	bool exp_result = false;
	par.lex->next();
	bool result = par.analyse_predicate();
	QVERIFY2(result==exp_result,"returned values are not the same at test_analyse_predicate_test5");
	compare_vectors(args_type,par.predargstypes["car"],"test_analyse_predicate_test5");
	QVERIFY2(pred_args.operator==(par.predargstypes),"Keys of maps are not equal test_analyse_predicate_test5");
	
}

//Тест на скобки, возможно использование ()
void parser_test::test_analyse_predicate_test6()
{
	cpplexer* lex =new cpplexer;
	//Вызывается для предиката year() без аргументов
	lex->createBufferFromString("year()\nCLAUSES");
	parser par(lex);
	QMap<QString, QVector<type> > pred_args;
	QVector<type> args_type;
	pred_args["year"] = args_type;
	bool exp_result = false;
	par.lex->next();
	bool result = par.analyse_predicate();
	QVERIFY2(result==exp_result,"returned values are not the same at test_analyse_predicate_test6");
	compare_vectors(args_type,par.predargstypes["year"],"test_analyse_predicate_test6");
	QVERIFY2(pred_args.operator==(par.predargstypes),"Keys of maps are not equal test_analyse_predicate_test6");
	
}

//несколько одинаковых типов, но не подряд идущих
void parser_test::test_analyse_predicate_test7()
{
	cpplexer* lex =new cpplexer;
	//Выполняется для предиката value(string,integer,string,integer,symbol,string)
	lex->createBufferFromString("value(string,integer,string,integer,string)\nCLAUSES");
	parser par(lex);
	QMap<QString, QVector<type> > pred_args;
	QVector<type> args_type;
	args_type<<String<<Integer<<String<<Integer<<String;
	pred_args["value"] = args_type;
	bool exp_result = false;
	par.lex->next();
	bool result = par.analyse_predicate();
	QVERIFY2(result==exp_result,"returned values are not the same at test_analyse_predicate_test7");
	compare_vectors(args_type,par.predargstypes["value"],"test_analyse_predicate_test7");
	QVERIFY2(pred_args.operator==(par.predargstypes),"Keys of maps are not equal test_analyse_predicate_test7");
}

//тест на отсутствие имени предиката
void parser_test::test_analyse_predicate_test8()
{
	cpplexer* lex =new cpplexer;
	//Выполняется для предиката (string,integer)
	lex->createBufferFromString("(string,integer)");
	parser par(lex);
	char exp_result[100];
	try
	{
		par.lex->next();
	    par.analyse_predicate();
	} catch(char*result)
	{
	strcpy(exp_result,"Error in the description of the predicate: there are no predicate and opening parenthesis");
	QVERIFY2(strcmp(exp_result,result)==0,"Different errors in test_analyse_predicate_test8 returned");
	}

}

//тест на отсутствие скобок
void parser_test::test_analyse_predicate_test9()
{
	cpplexer* lex =new cpplexer;
	//Выполняется для предиката age string,integer
	lex->createBufferFromString("age string,integer");
	parser par(lex);
	char exp_result[100];
	par.lex->next();
	try
	{
	 par.analyse_predicate();
	} catch(char*result)
	{
	strcpy(exp_result,"Error in the description of the predicate: there are no predicate and opening parenthesis");
	QVERIFY2(strcmp(exp_result,result)==0,"Different errors in test_analyse_predicate_test9 returned");
	}

}

//тест на присутствие нескольких запятых  в предикате 
void parser_test::test_analyse_predicate_test10()
{
	cpplexer* lex =new cpplexer;
	//Выполняется для предиката year (string,,,,integer)
	lex->createBufferFromString("year (string,,,,integer)");
	parser par(lex);
	char exp_result[100];
	par.lex->next();
	try
	{
	 par.analyse_predicate();
	} catch(char*result)
	{
	strcpy(exp_result,"Error in the description of the predicate: there is no type");
	QVERIFY2(strcmp(exp_result,result)==0,"Different errors in test_analyse_predicate_test10 returned");
	}

}

//тест на присутствие посторонних символов в предикате
void parser_test::test_analyse_predicate_test11()
{
	cpplexer* lex =new cpplexer;
	//Выполняется для предиката year (string!integer)
	lex->createBufferFromString("year (string!integer)");
	parser par(lex);
	char exp_result[100];
	par.lex->next();
	try
	{
	 par.analyse_predicate();
	} catch(char*result)
	{
	strcpy(exp_result,"Error in the description of the predicate: there is no separator between the types");
	QVERIFY2(strcmp(exp_result,result)==0,"Different errors in test_analyse_predicate_test11 returned");
	}
}

//Тест на возвращение Int
void parser_test::test_get_type_test1()
{
	type exp_type = Integer;
	type result = variable::get_type("34");
	QVERIFY2(exp_type==result,"Different results in test_get_type_test1");
}

//Тест на возвращение real
void parser_test::test_get_type_test2()
{
	type exp_type = Real;
	type result = variable::get_type("34.5");
	QVERIFY2(exp_type==result,"Different results in test_get_type_test2");
}

//Тест на возвращение char
void parser_test::test_get_type_test3()
{
	type exp_type = Char;
	type result = variable::get_type("'e'");
	QVERIFY2(exp_type==result,"Different results in test_get_type_test3");
}

//Тест на возвращение string
void parser_test::test_get_type_test4()
{
	type exp_type = String;
	type result = variable::get_type("\"string\"");
	QVERIFY2(exp_type==result,"Different results in test_get_type_test4");
}

//Тест на возвращение symbol
void parser_test::test_get_type_test5()
{
	type exp_type = Char;
	type result = variable::get_type("'!'");
	QVERIFY2(exp_type==result,"Different results in test_get_type_test5");
}

//Тест на возвращение char служебных символов  \n
void parser_test::test_get_type_test6()
{
	type exp_type = Char;
	type result = variable::get_type("'\\n'");
	QVERIFY2(exp_type==result,"Different results in test_get_type_test6");
}

//Тест на возвращение char \\ символов 
void parser_test::test_get_type_test7()
{
	type exp_type = Char;
	type result = variable::get_type("'\\\\'");
	QVERIFY2(exp_type==result,"Different results in test_get_type_test7");
}

//Тест на возвращение char служебных символов - апостроф
void parser_test::test_get_type_test8()
{
	type exp_type = Char;
	type result = variable::get_type("'\\''");
	QVERIFY2(exp_type==result,"Different results in test_get_type_test8");
}

//Тест на ошибку - некорректный тип
void parser_test::test_get_type_test9()
{
	/*char*exp_result;
	strcpy(exp_result,"Incorrect type of variable");
	try
	{
	type result = variable::get_type("3q-");
	}
	catch(char*result)
	{
		QVERIFY2(strcmp(exp_result,result)!=0,"Different errors in test_get_type_test8 returned");
	}*/
}

//Тест на ошибку - некорректный тип
void parser_test::test_get_type_test10()
{
	/*char*exp_result;
	strcpy(exp_result,"Incorrect type of variable");
	try
	{
	type result = variable::get_type("'erty'");
	}
	catch(char*result)
	{
		QVERIFY2(strcmp(exp_result,result)!=0,"Different errors in test_get_type_test9 returned");
	}*/
}

//Тест на ошибку - некорректный тип
void parser_test::test_get_type_test11()
{
	/*char*exp_result;
	strcpy(exp_result,"Incorrect type of variable");
	try
	{
	type result = variable::get_type("-_");
	}
	catch(char*result)
	{
		QVERIFY2(strcmp(exp_result,result)!=0,"Different errors in test_get_type_test10 returned");
	}*/
}

//Тест на числовую строку
void parser_test::test_get_type_test12()
{
	type exp_type = String;
	type result = variable::get_type("\"12345\"");
	QVERIFY2(exp_type==result,"Different results in test_get_type_test12");
}

//Тест - строка из одного символа
void parser_test::test_get_type_test13()
{
	type exp_type = String;
	type result = variable::get_type("\"?\"");
	QVERIFY2(exp_type==result,"Different results in test_get_type_test13");
}

//Тест - пустая строка
void parser_test::test_get_type_test14()
{
	type exp_type = String;
	type result = variable::get_type("\"\"");
	QVERIFY2(exp_type==result,"Different results in test_get_type_test14");
}

//Второй аргумент предиката подходит
void parser_test::test_check_declared_type_test1()
{
	//для предиката open(string,integer)
	bool exp_type = true;
	bool result = variable::check_declared_type("34");
	QVERIFY2(exp_type==result,"Different results in test_check_declared_type_test1");
}

//Первый аргумент предиката подходит
void parser_test::test_check_declared_type_test2()
{
	//для предиката open(string,integer)
	bool exp_type = true;
	bool result = variable::check_declared_type("\"str\"");
	QVERIFY2(exp_type==result,"Different results in test_check_declared_type_test1");
}

//Оба аргумента предиката подходят
void parser_test::test_check_declared_type_test3()
{
	//для предиката open(integer,integer)
	bool exp_type = true;
	bool result = variable::check_declared_type("\"str\"");
	QVERIFY2(exp_type==result,"Different results in test_check_declared_type_test1");
}

//Аргумент - символ
void parser_test::test_check_declared_type_test4()
{
	//для предиката open(symbol,integer)
	bool exp_type = true;
	bool result = variable::check_declared_type("\'s\'");
	QVERIFY2(exp_type==result,"Different results in test_check_declared_type_test1");
}

//Аргумент - служебный символ
void parser_test::test_check_declared_type_test5()
{
	//для предиката open(symbol,integer)
	bool exp_type = true;
	bool result = variable::check_declared_type("'\\n'");
	QVERIFY2(exp_type==result,"Different results in test_check_declared_type_test1");
}

//Аргумент - типа float
void parser_test::test_check_declared_type_test6()
{
	//для предиката open(symbol,real)
	bool exp_type = true;
	bool result = variable::check_declared_type("44.7");
	QVERIFY2(exp_type==result,"Different results in test_check_declared_type_test1");
}

//Нет аргумента заданного типа
void parser_test::test_check_declared_type_test7()
{
	//для предиката open(symbol,real)
	bool exp_type = true;
	bool result = variable::check_declared_type("65");
	QVERIFY2(exp_type==result,"Different results in test_check_declared_type_test1");
}

//Нет аргумента заданного типа
void parser_test::test_check_declared_type_test8()
{
	//для предиката open(symbol,real)
	bool exp_type = true;
	bool result = variable::check_declared_type("\"str\"");
	QVERIFY2(exp_type==result,"Different results in test_check_declared_type_test1");
}

//Ошибка в типе
void parser_test::test_check_declared_type_test9()
{
	//для предиката open(symbol,real)
	//char*exp_result;
	//strcpy(exp_result,"Incorrect type of variable");
	//try
	//{
	//bool result = variable::check_declared_type("-_");
	//}
	//catch(char*result)
	//{
	//	QVERIFY2(strcmp(exp_result,result)!=0,"Different errors in test_check_declared_type_test9 returned");
	//}
}

//Ошибка в типе
void parser_test::test_check_declared_type_test10()
{
	//для предиката open(symbol,real)
	/*char*exp_result;
	strcpy(exp_result,"Incorrect type of variable");
	try
	{
	bool result = variable::check_declared_type("3qq");
	}
	catch(char*result)
	{
		QVERIFY2(strcmp(exp_result,result)!=0,"Different errors in test_check_declared_type_test10 returned");
	}*/
}

//Присвоение значения типа int переменной
void parser_test::test_determine_value_test1()
{
	variable temp;
	type exp_type = Integer;
	c_type exp_value;
	exp_value.i = 3;
	type result;
	temp.determine_value("3");
	result = temp.get_vartype();
	QVERIFY2(exp_type==result,"Different types in test_determine_value_test1");
	QVERIFY2(exp_value.i==temp.get_value()->i,"Different values in test_determine_value_test1");
}

//Присвоение значения типа real переменной
void parser_test::test_determine_value_test2()
{
	variable temp;
	type exp_type = Real;
	c_type exp_value;
	exp_value.f = 3.7;
	type result;
	temp.determine_value("3.7");
	result = temp.get_vartype();
	QVERIFY2(exp_type==result,"Different results in test_determine_value_test2");
	QVERIFY2(exp_value.f==temp.get_value()->f,"Different values in test_determine_value_test2");
}


//Присвоение значения типа str переменной
void parser_test::test_determine_value_test3()
{
	variable temp;
	type exp_type = String;
	c_type exp_value;
	exp_value.s = "\"String\"";
	type result;
	temp.determine_value("\"String\"");
	result = temp.get_vartype();
	QVERIFY2(exp_type==result,"Different results in test_determine_value_test3");
	c_type* c= temp.get_value();
	QVERIFY2(strcmp(exp_value.s,temp.get_value()->s) == 0,"Different values in test_determine_value_test3");
}

//Присвоение значения типа char переменной
void parser_test::test_determine_value_test4()
{
	variable temp;
	type exp_type = Char;
	c_type exp_value;
	exp_value.c = 'S';
	type result;
	temp.determine_value("\'S\'");
	result = temp.get_vartype();
	QVERIFY2(exp_type==result,"Different results in test_determine_value_test4");
	QVERIFY2(exp_value.c==temp.get_value()->c,"Different values in test_determine_value_test4");
}

//Присвоение значения типа symbol переменной
void parser_test::test_determine_value_test5()
{
	variable temp;
	type exp_type = String;
	c_type exp_value;
	exp_value.s  = "\"!\"";
	type result;
	temp.determine_value("\"!\"");
	result = temp.get_vartype();
	QVERIFY2(exp_type==result,"Different results in test_determine_value_test5");
	QVERIFY2(strcmp(exp_value.s,temp.get_value()->s) == 0,"Different values in test_determine_value_test5");
}

//Присвоение значения типа char (служебный символ) переменной
void parser_test::test_determine_value_test6()
{
	variable temp;
	type exp_type = Char;
	c_type exp_value;
	exp_value.c = '\n';
	type result;
	temp.determine_value("'\\n'");
	result = temp.get_vartype();
	QVERIFY2(exp_type==result,"Different results in test_determine_value_test6");
	QVERIFY2(exp_value.c==temp.get_value()->c,"Different values in test_determine_value_test6");
}

//Присвоение значения типа char (служебный символ) переменной
void parser_test::test_determine_value_test7()
{
	variable temp;
	type exp_type = Char;
	c_type exp_value;
	exp_value.c = '\\';
	type result;
	temp.determine_value("'\\\\'");
	result = temp.get_vartype();
	QVERIFY2(exp_type==result,"Different results in test_determine_value_test7");
	QVERIFY2(exp_value.c==temp.get_value()->c,"Different values in test_determine_value_test7");
}

//Присвоение значения типа char (служебный символ) переменной
void parser_test::test_determine_value_test8()
{
	variable temp;
	type exp_type = Char;
	c_type exp_value;
	exp_value.c = '\'\'';
	type result;
	temp.determine_value("'\\''");  
	result = temp.get_vartype();
	QVERIFY2(exp_type==result,"Different results in test_determine_value_test8");
	QVERIFY2(exp_value.c==temp.get_value()->c,"Different values in test_determine_value_test8");
}

//Тест на isEverything
void parser_test::test_determine_value_test9()
{
	variable temp;
	bool exp_result = true;
	temp.determine_value("_");  
	bool result = temp.is_everything();
	QVERIFY2(exp_result==result,"Different results in test_determine_value_test8");
}

// Тест для элементарного goal
void parser_test::test_analyse_goal_test1()
{
	cpplexer* l = new cpplexer;
	QMap<QString, int> indexs;
	l->createBufferFromString("open(string,real)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("open(X,Y).");
	g.lex = l;
	//Для goal вида open(X,Y).
	predicate exp_goal;//
	exp_goal.add_predicate_description();
	predicate temp;//Предикат в цели
	variable* x = new variable();
	variable* y = new variable();
	QVector<variable*> vars; //Вектор переменных
	x->set_value(NULL);
	y->set_value(NULL);
	x->set_index(0);
	y->set_index(1);
	x->set_vartype(String);
	y->set_vartype(Real);
	vars<<x<<y;
	exp_goal.add_arguments(vars,0);
	indexs.insert("X",0);
	indexs.insert("Y",1);
	exp_goal.add_argindexs(indexs,0);
	temp.add_predicate_description();
	temp.add_arguments(vars,0);
	QVector<predicate> pred; //Вектор использованных предикатов
	temp.set_name("open");
	pred<<temp;
	exp_goal.add_usedpredicates(pred,0);
	g.analyse_goal();
	QVERIFY2(g.get_goal() == exp_goal,"test_analyse_goal_test1");		
}

// Тест с объединением целей через ,
void parser_test::test_analyse_goal_test2()
{
	QMap<QString, int> indexs;
	cpplexer* l = new cpplexer;
	l->createBufferFromString("open(string,integer)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("close(string)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("open(X,Y), close(X).");
	g.lex = l;
	//g.lex->next();
	//Для goal вида open(X,Y), close(X).
	predicate exp_goal, temp1, temp2;
	temp1.add_predicate_description();
	temp2.add_predicate_description();
	temp1.set_name("open");
	temp2.set_name("close");
	variable* x = new variable();
	variable* y = new variable();
	x->set_value(NULL);
	y->set_value(NULL);
	x->set_vartype(String);
	y->set_vartype(Integer);
	x->set_index(0);
	y->set_index(1);
	x->set_vartype(String);
	y->set_vartype(Integer);
	x->set_index(0);
	y->set_index(1);
	QVector<predicate> pred;
	QVector<variable*> vars;
	vars<<x<<y;
	temp1.add_arguments(vars,0);
	exp_goal.add_predicate_description();
	exp_goal.add_arguments(vars,0);
	vars.clear();
	vars<<x;
	temp2.add_arguments(vars,0);
	pred<<temp1<<temp2;
	exp_goal.add_usedpredicates(pred,0);
	indexs.insert("X",0);
	indexs.insert("Y",1);
	exp_goal.add_argindexs(indexs,0);
	g.analyse_goal();
	QVERIFY2(g.get_goal() == exp_goal,"test_analyse_goal_test2");		
}

// Тест с объединением целей через ;
void parser_test::test_analyse_goal_test3()
{
	QMap<QString, int> indexs;
	cpplexer* l = new cpplexer;
	l->createBufferFromString("open(integer,char)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("close(real)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("open(X,Y);close(X).");
	g.lex = l;
	//g.lex->next();
	//Для goal вида open(X,Y);close(X).
	predicate exp_goal, temp1, temp2;
	temp1.set_name("open");
	temp2.set_name("close");
	temp1.add_predicate_description();
	temp2.add_predicate_description();
	//for(int i=0;i<2;i++)
	exp_goal.add_predicate_description();
	exp_goal.add_predicate_description();
	variable* x = new variable();
	variable* x1 = new variable();
	variable* y = new variable();
	x->set_value(NULL);
	y->set_value(NULL);
	x->set_index(0);
	y->set_index(1);
	x->set_vartype(Integer);
	y->set_vartype(Char);
	QVector<predicate> pred;
	QVector<variable*> vars;
	vars<<x<<y;
	temp1.add_arguments(vars,0);
	exp_goal.add_arguments(vars,0);
	vars.clear();
	x1->set_vartype(Real);
	x1->set_index(0);
	x1->set_value(NULL);
	vars<<x1;
	temp2.add_arguments(vars,0);
	exp_goal.add_arguments(vars,1);
	pred<<temp1;
	exp_goal.add_usedpredicates(pred,0);
	indexs.insert("X",0);
	indexs.insert("Y",1);
	exp_goal.add_argindexs(indexs,0);
	indexs.clear();
	indexs.insert("X",0);
	exp_goal.add_argindexs(indexs,1);
	pred.clear();
	pred<<temp2;
	exp_goal.add_usedpredicates(pred,1);
	g.analyse_goal();
	QVERIFY2(g.get_goal() == exp_goal,"test_analyse_goal_test3");		
}

// Тест с объединением целей через ; и ,
void parser_test::test_analyse_goal_test4()
{
	QMap<QString, int> indexs;
	cpplexer* l = new cpplexer;
	l->createBufferFromString("open(integer,char)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("close(real)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("move(string)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("open(X,Y);close(X), move(Z).");
	g.lex = l;
	//g.lex->next();
	//Для goal вида open(X,Y);close(X), move(Z).
	predicate exp_goal, temp1, temp2, temp3;
	temp1.add_predicate_description();
	temp2.add_predicate_description();
	temp3.add_predicate_description();
	exp_goal.add_predicate_description();
	exp_goal.add_predicate_description();
	temp1.set_name("open");
	temp2.set_name("close");
	temp3.set_name("move");
	variable* x = new variable();
	variable* x1 = new variable();
	variable* y = new variable();
	variable* z = new variable();
	x->set_value(NULL);
	x1->set_value(NULL);
	y->set_value(NULL);
	z->set_value(NULL);
	x->set_index(0);
	x1->set_index(0);
	y->set_index(1);
	z->set_index(0);
	x->set_vartype(Integer);
	y->set_vartype(Char);
	z->set_vartype(String);
	QVector<predicate> pred;
	QVector<variable*> vars;
	vars<<x<<y;
	temp1.add_arguments(vars,0);
	exp_goal.add_arguments(vars,0);
	vars.clear();
	x1->set_vartype(Real);
	vars<<x1;
	temp2.add_arguments(vars,0);
	vars.clear();
	vars<<z;
	temp3.add_arguments(vars,0);
	vars.clear();
	vars<<x1<<z;
	exp_goal.add_arguments(vars,1);
	pred<<temp1;
	exp_goal.add_usedpredicates(pred,0);
	indexs.insert("X",0);
	indexs.insert("Y",1);
	exp_goal.add_argindexs(indexs,0);
	indexs.clear();
	indexs.insert("X",0);
	indexs.insert("Z",1);
	exp_goal.add_argindexs(indexs,1);
	pred.clear();
	pred<<temp2<<temp3;
	exp_goal.add_usedpredicates(pred,1);
	g.analyse_goal();
	QVERIFY2(g.get_goal() == exp_goal,"test_analyse_goal_test4");		
}

// Тест с объединением целей через ; 
void parser_test::test_analyse_goal_test5()
{
	QMap<QString, int> indexs;
	cpplexer* l = new cpplexer;
	l->createBufferFromString("open(integer,char)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("close(real)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("move(string,integer)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("open(X,Y);close(X); move(Z,X).");
	g.lex = l;
	//g.lex->next();
	//Для goal вида open(X,Y);close(X); move(Z,X).
	predicate exp_goal, temp1, temp2, temp3;
	temp1.add_predicate_description();
	temp2.add_predicate_description();
	temp3.add_predicate_description();
	exp_goal.add_predicate_description();
	exp_goal.add_predicate_description();
	exp_goal.add_predicate_description();
	temp1.set_name("open");
	temp2.set_name("close");
	temp3.set_name("move");
	variable* x = new variable();
	variable* x1 = new variable();
	variable* x2 = new variable();
	variable* y = new variable();
	variable* z = new variable();
	y->set_index(1);
	z->set_index(0);
	x->set_value(NULL);
	y->set_value(NULL);
	z->set_value(NULL);
	x->set_vartype(Integer);
	y->set_vartype(Char);
	z->set_vartype(String);
	QVector<predicate> pred;
	QVector<variable*> vars;
	vars<<x<<y;
	temp1.add_arguments(vars,0);
	exp_goal.add_arguments(vars,0);
	vars.clear();
	x1->set_index(0);
	x1->set_value(NULL);
	x1->set_vartype(Real);
	vars<<x1;
	temp2.add_arguments(vars,0);
	exp_goal.add_arguments(vars,1);
	vars.clear();
	x2->set_index(1);
	x2->set_value(NULL);
	x2->set_vartype(Integer);
	vars<<z<<x2;
	temp3.add_arguments(vars,0);
	exp_goal.add_arguments(vars,2);
	pred<<temp1;
	exp_goal.add_usedpredicates(pred,0);
	pred.clear();
	pred<<temp2;
	exp_goal.add_usedpredicates(pred,1);
	pred.clear();
	exp_goal.add_usedpredicates(pred,2);
	indexs.insert("X",0);
	indexs.insert("Y",1);
	exp_goal.add_argindexs(indexs,0);
	indexs.clear();
	indexs.insert("X",0);
	exp_goal.add_argindexs(indexs,1);
	indexs.clear();
	indexs.insert("Z",0);
	indexs.insert("X",1);
	exp_goal.add_argindexs(indexs,2);
	g.analyse_goal();
	QVERIFY2(g.get_goal() == exp_goal,"test_analyse_goal_test5");		
}

//Тест с одной переменной, имеющей конкретный тип real
void parser_test::test_analyse_goal_test6()
{
	QMap<QString, int> indexs;
	cpplexer* l = new cpplexer;
	l->createBufferFromString("open(real,char)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("open(5.5,Y).");
	g.lex = l;
	//g.lex->next();
	//Для goal вида open(5.5,Y).
	predicate exp_goal;//
	predicate temp;//Предикат в цели
	exp_goal.add_predicate_description();
	temp.add_predicate_description();
	variable* x = new variable();
	variable* y = new variable();
	QVector<variable*> vars; //Вектор переменных
	x->determine_value("5.5");
	y->set_value(NULL);
	y->set_vartype(Char);
	y->set_index(1);
	vars<<x<<y;
	temp.add_arguments(vars,0);
	vars.clear();
	vars<<y;
	exp_goal.add_arguments(vars,0);
	QVector<predicate> pred; //Вектор использованных предикатов
	temp.set_name("open");
	pred<<temp;
	exp_goal.add_usedpredicates(pred,0);
	indexs.insert("Y",0);
	exp_goal.add_argindexs(indexs,0);
	g.analyse_goal();
	QVERIFY2(g.get_goal() == exp_goal,"test_analyse_goal_test6");		
}

//Тест с одной переменной, имеющей конкретный тип integer
void parser_test::test_analyse_goal_test7()
{
	QMap<QString, int> indexs;
	cpplexer* l = new cpplexer;
	l->createBufferFromString("open(integer,string)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("open(5,Y).");
	g.lex = l;
	//Для goal вида open(5,Y).
	predicate exp_goal;//
	predicate temp;//Предикат в цели
	exp_goal.add_predicate_description();
	temp.add_predicate_description();
	variable* x = new variable();
	variable* y = new variable();
	QVector<variable*> vars; //Вектор переменных
	x->determine_value("5");
	y->set_vartype(String);
	y->set_value(NULL);
	y->set_index(1);
	vars<<x<<y;
	temp.add_arguments(vars,0);
	vars.clear();
	vars<<y;
	exp_goal.add_arguments(vars,0);
	QVector<predicate> pred; //Вектор использованных предикатов
	temp.set_name("open");
	pred<<temp;
	exp_goal.add_usedpredicates(pred,0);
	indexs.insert("Y",0);
	exp_goal.add_argindexs(indexs,0);
	g.analyse_goal();
	QVERIFY2(g.get_goal() == exp_goal,"test_analyse_goal_test7");		
}

//Тест с одной переменной, имеющей конкретный тип char
void parser_test::test_analyse_goal_test8()
{
	QMap<QString, int> indexs;
	cpplexer* l = new cpplexer;
	l->createBufferFromString("open(char,string)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("open('R',Y).");
	g.lex = l;
	//Для goal вида open('R',Y).
	predicate exp_goal;//
	predicate temp;//Предикат в цели
	exp_goal.add_predicate_description();
	temp.add_predicate_description();
	variable* x = new variable();
	variable* y = new variable();
	y->set_vartype(String);
	QVector<variable*> vars; //Вектор переменных
	x->determine_value("\'R\'");
	y->set_value(NULL);
	y->set_index(1);
	vars<<x<<y;
	temp.add_arguments(vars,0);
	vars.clear();
	vars<<y;
	exp_goal.add_arguments(vars,0);
	QVector<predicate> pred; //Вектор использованных предикатов
	temp.set_name("open");
	pred<<temp;
	exp_goal.add_usedpredicates(pred,0);
	indexs.insert("Y",0);
	exp_goal.add_argindexs(indexs,0);
	g.analyse_goal();
	QVERIFY2(g.get_goal() == exp_goal,"test_analyse_goal_test8");		
}

//Тест с одной переменной, имеющей конкретный тип string
void parser_test::test_analyse_goal_test9()
{
	QMap<QString, int> indexs;
	cpplexer* l = new cpplexer;
	l->createBufferFromString("open(string,string)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("open(\"str\",Y).");
	g.lex = l;
	//Для goal вида open("str",Y).
	predicate exp_goal;//
	predicate temp;//Предикат в цели
	exp_goal.add_predicate_description();
	temp.add_predicate_description();
	variable *x = new variable();
	variable* y = new variable();
	QVector<variable*> vars; //Вектор переменных
	x->determine_value("\"str\"");
	y->set_value(NULL);
	y->set_vartype(String);
	y->set_index(1);
	vars<<x<<y;
	temp.add_arguments(vars,0);
	vars.clear();
	vars<<y;
	exp_goal.add_arguments(vars,0);
	QVector<predicate> pred; //Вектор использованных предикатов
	temp.set_name("open");
	pred<<temp;
	exp_goal.add_usedpredicates(pred,0);
	indexs.insert("Y",0);
	exp_goal.add_argindexs(indexs,0);
	g.analyse_goal();
	QVERIFY2(g.get_goal() == exp_goal,"test_analyse_goal_test9");		
}


//Тест с двумя переменными, имеющими одинаковые типы
void parser_test::test_analyse_goal_test10()
{
	QMap<QString, int> indexs;
	cpplexer* l = new cpplexer;
	l->createBufferFromString("open(real,real)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("open(3.5,5.7).");
	g.lex = l;
	//Для goal вида open(3.5,5.7).
	predicate exp_goal;//
	predicate temp;//Предикат в цели
	exp_goal.add_predicate_description();
	temp.add_predicate_description();
	variable* x = new variable();
	variable* y = new variable();
	QVector<variable*> vars; //Вектор переменных
	x->determine_value("3.5");
	y->determine_value("5.7");
	vars<<x<<y;
	temp.add_arguments(vars,0);
	QVector<predicate> pred; //Вектор использованных предикатов
	temp.set_name("open");
	pred<<temp;
	exp_goal.add_usedpredicates(pred,0);
	exp_goal.add_argindexs(indexs,0);
	g.analyse_goal();
	QVERIFY2(g.get_goal() == exp_goal,"test_analyse_goal_test10");		
}

//Тест с несколькими предикатами с заданным значением, записанными через ,
void parser_test::test_analyse_goal_test11()
{
	QMap<QString, int> indexs;
	cpplexer* l = new cpplexer;
	l->createBufferFromString("open(real,char)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("close(real,string)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("open(3.5,Y), close(X,\"str\").");
	g.lex = l;
	//Для goal вида open(3.5,Y), close(X,"string").
	predicate exp_goal;//
	predicate temp,  temp1;//Предикат в цели
	temp.add_predicate_description();
	temp1.add_predicate_description();
	exp_goal.add_predicate_description();
	variable* x = new variable();
	variable* y = new variable();
	variable* y1 = new variable();
	variable* x1 = new variable();
	QVector<variable*> vars; //Вектор переменных
	y->set_value(NULL);
	y->set_vartype(Char);
	y->set_index(0);
	x->determine_value("3.5");
	vars<<x<<y;
	temp.add_arguments(vars,0);
	vars.clear();
	x1->set_value(NULL);
	x1->set_vartype(Real);
	x1->set_index(0);
	vars<<y<<x1;
	exp_goal.add_arguments(vars,0);
	QVector<predicate> pred; //Вектор использованных предикатов
	temp.set_name("open");
	pred<<temp;
	vars.clear();
	y1->determine_value("\"str\"");
	vars<<x1<<y1;
	temp1.set_name("close");
	temp1.add_arguments(vars,0);
	pred<<temp1;
	exp_goal.add_usedpredicates(pred,0);
	indexs.insert("Y",0);
	indexs.insert("X",1);
	exp_goal.add_argindexs(indexs,0);
	g.analyse_goal();
	QVERIFY2(g.get_goal() == exp_goal,"test_analyse_goal_test11");		
}


// Тест с объединением целей через ; , аргументы предикатов имеют некоторый тип и значение
void parser_test::test_analyse_goal_test12()
{
	QMap<QString, int> indexs;
	cpplexer* l = new cpplexer;
	l->createBufferFromString("open(char,real)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("close(integer)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("age(string)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("open(\'a\',5.6);close(3);age(\"Years\").");
	g.lex = l;
	//Для goal вида open('a',5.6);close(3);age("Years").
	predicate exp_goal, temp1, temp2,temp3;
	temp1.add_predicate_description();
	temp2.add_predicate_description();
	temp3.add_predicate_description();
	exp_goal.add_predicate_description();
	exp_goal.add_predicate_description();
	exp_goal.add_predicate_description();
	temp1.set_name("open");
	temp2.set_name("close");
	temp3.set_name("age");
	variable* x = new variable();
	variable* y = new variable();
	x->determine_value("\'a\'");
	y->determine_value("5.6");
	QVector<predicate> pred;
	QVector<variable*> vars;
	vars<<x<<y;
	temp1.add_arguments(vars,0);
	vars.clear();
	x->determine_value("3");
	vars<<x;
	temp2.add_arguments(vars,0);
	vars.clear();
	x->determine_value("\"Years\"");
	vars<<x;
	temp3.add_arguments(vars,0);
	pred<<temp1;
	exp_goal.add_usedpredicates(pred,0);
	pred.clear();
	pred<<temp2;
	exp_goal.add_usedpredicates(pred,1);
	pred.clear();
	pred<<temp3;
	exp_goal.add_usedpredicates(pred,2);
	exp_goal.add_argindexs(indexs,0);
	g.analyse_goal();
	QVERIFY2(g.get_goal() == exp_goal,"test_analyse_goal_test12");		
}

// Тест с объединением целей через ; , аргументы предикатов имеют некоторый тип и значение
void parser_test::test_analyse_goal_test13()
{
	QMap<QString, int> indexs;
	cpplexer* l = new cpplexer;
	l->createBufferFromString("open(char,real)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("close(integer)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("age(string)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("open(\'a\',5.6), close(3);age(\"Years\").");
	g.lex = l;
	//Для goal вида open('a',5.6), close(3);age("Years").
	predicate exp_goal, temp1, temp2,temp3;
	temp1.add_predicate_description();
	temp2.add_predicate_description();
	temp3.add_predicate_description();
	exp_goal.add_predicate_description();
	exp_goal.add_predicate_description();
	temp1.set_name("open");
	temp2.set_name("close");
	temp3.set_name("age");
	variable* x = new variable();
	variable* y = new variable();
	x->determine_value("\'a\'");
	y->determine_value("5.6");
	QVector<predicate> pred;
	QVector<variable*> vars;
	vars<<x<<y;
	temp1.add_arguments(vars,0);
	vars.clear();
	x->determine_value("3");
	vars<<x;
	temp2.add_arguments(vars,0);
	vars.clear();
	x->determine_value("\"Years\"");
	vars<<x;
	temp3.add_arguments(vars,0);
	pred<<temp1<<temp2;
	exp_goal.add_usedpredicates(pred,0);
	pred.clear();
	pred<<temp3;
	exp_goal.add_usedpredicates(pred,1);
	exp_goal.add_argindexs(indexs,0);
	g.analyse_goal();
	QVERIFY2(g.get_goal() == exp_goal,"test_analyse_goal_test13");		
}


//Тест для простейшего clause, значения аргументов не заданы
void parser_test::test_analyse_clause_test1()
{
	cpplexer* l = new cpplexer;
	l->createBufferFromString("mother(real, char)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("parent(real, char)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("female(real)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("mother(X, Y):-parent(X, Y), female(X).");
	g.lex = l;
	predicate result, temp1,temp2;
	temp1.add_predicate_description();
	temp2.add_predicate_description();
	result.add_predicate_description();
	variable* x = new variable();
	variable* y = new variable();
	x->set_value(NULL);
	y->set_value(NULL);
	x->set_vartype(Real);
	y->set_vartype(Char);
	QVector<predicate> pred;
	QVector<variable*> vars;
	vars<<x<<y;
	temp1.set_name("parent");
	temp1.add_arguments(vars,0);
	result.add_arguments(vars,0);
	vars.clear();
	vars<<x;
	temp2.add_arguments(vars,0);
	temp2.set_name("female");
	pred<<temp1<<temp2;
	result.set_name("mother");
	result.add_usedpredicates(pred,0);
	QMap <QString, int> argsindexs;
	argsindexs.insert("X",0);
	argsindexs.insert("Y",1);
	result.add_argindexs(argsindexs, 0);
	g.lex->next();
	g.analyse_clause();
	QVERIFY2(*(g.get_predicate(result.get_name())) == result,"test_analyse_clause_test1");
	
}

//Тест для простейшего clause, значения аргументов не заданы, предикаты объединены через ,
void parser_test::test_analyse_clause_test2()
{
	cpplexer* l = new cpplexer;
	l->createBufferFromString("mother(real, char)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("parent(real, char)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("female(real)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("mother(X, Y):-parent(X, Y); female(X).");
	g.lex = l;
	predicate result, temp1,temp2;
	temp1.add_predicate_description();
	temp2.add_predicate_description();
	for(int i=0;i<2;i++)
	result.add_predicate_description();
	variable* x = new variable();
	variable* y = new variable();
	x->set_value(NULL);
	y->set_value(NULL);
	x->set_vartype(Real);
	y->set_vartype(Char);
	QVector<predicate> pred;
	QVector<variable*> vars;
	vars<<x<<y;
	temp1.set_name("parent");
	temp1.add_arguments(vars,0);
	result.add_arguments(vars,0);
	result.add_arguments(vars,1);
	vars.clear();
	vars<<x;
	temp2.add_arguments(vars,0);
	temp2.set_name("female");
	pred<<temp1;
	result.set_name("mother");
	result.add_usedpredicates(pred,0);
	pred.clear();
	pred<<temp2;
	result.add_usedpredicates(pred,1);
	QMap <QString, int> argsindexs;
	argsindexs.insert("X",0);
	argsindexs.insert("Y",1);
	result.add_argindexs(argsindexs, 0);
	result.add_argindexs(argsindexs, 1);
	g.lex->next();
	g.analyse_clause();
	QVERIFY2(*(g.get_predicate(result.get_name())) == result,"test_analyse_clause_test2");
	
}

//Тест для clause, значения аргументов не заданы, предикаты объединены через , и ;
void parser_test::test_analyse_clause_test3()
{
	cpplexer* l = new cpplexer;
	l->createBufferFromString("animal(integer, string)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("parent(integer, string)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("female(integer)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("home(string)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("animal(X, Y):-parent(X, Y); female(X), home(Y).");
	g.lex = l;
	predicate result, temp1,temp2,temp3;
	temp1.add_predicate_description();
	temp2.add_predicate_description();
	temp3.add_predicate_description();
	result.add_predicate_description();
	result.add_predicate_description();
	variable* x = new variable();
	variable* y = new variable();
	x->set_value(NULL);
	y->set_value(NULL);
	x->set_vartype(Integer);
	y->set_vartype(String);
	QVector<predicate> pred;
	QVector<variable*> vars;
	vars<<x<<y;
	temp1.set_name("parent");
	temp1.add_arguments(vars,0);
	result.add_arguments(vars,0);
	result.add_arguments(vars,1);
	vars.clear();
	vars<<x;
	temp2.add_arguments(vars,0);
	temp2.set_name("female");
	vars.clear();
	vars<<y;
	temp3.set_name("home");
	temp3.add_arguments(vars,0);
	pred<<temp1;
	result.set_name("animal");
	result.add_usedpredicates(pred,0);
	pred.clear();
	pred<<temp2<<temp3;
	result.add_usedpredicates(pred,1);
	QMap <QString, int> argsindexs;
	argsindexs.insert("X",0);
	argsindexs.insert("Y",1);
	result.add_argindexs(argsindexs, 0);
	result.add_argindexs(argsindexs, 1);
	g.lex->next();
	g.analyse_clause();
	QVERIFY2(*(g.get_predicate(result.get_name())) == result,"test_analyse_clause_test3");
}

//Тест для примитивного правила, где аргумент предиката имеет значение int 
void parser_test::test_analyse_clause_test4()
{
	cpplexer* l = new cpplexer;
	l->createBufferFromString("animal(integer, string)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("parent(char, string)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("animal(3, Y):-parent(\'t\', Y).");
	g.lex = l;
	predicate result, temp1;
	temp1.add_predicate_description();
	result.add_predicate_description();
	variable* x = new variable();
	variable* x1 = new variable();
	variable* y1 = new variable();
	variable* y = new variable();
	x->determine_value("3");
	y->set_value(NULL);
	y->set_index(1);
	y->set_vartype(String);
	QVector<predicate> pred;
	QVector<variable*> vars;
	vars<<x<<y;
	result.set_name("animal");
	result.add_arguments(vars,0);
	temp1.set_name("parent");
	x1->determine_value("\'t\'");
	y1->set_index(1);
	y1->set_value(NULL);
	y1->set_vartype(String);
	vars.clear();
	vars<<x1,y1;
	temp1.add_arguments(vars,0);
	pred<<temp1;
	result.add_usedpredicates(pred,0);
	QMap <QString, int> argsindexs;
	argsindexs.insert("Y",1);
	result.add_argindexs(argsindexs, 0);
	g.lex->next();
	g.analyse_clause();
	QVERIFY2(*(g.get_predicate(result.get_name())) == result,"test_analyse_clause_test4");
}

//Тест для примитивного правила, где все аргументы имеют различные значения
void parser_test::test_analyse_clause_test5()
{
	cpplexer* l = new cpplexer;
	l->createBufferFromString("animal(integer, string)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("parent(real, char)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("animal(3, \"str\"):-parent(4.5, \'t\').");
	g.lex = l;
	predicate result, temp1;
	temp1.add_predicate_description();
	result.add_predicate_description();
	variable* x = new variable();
	variable* y = new variable();
	variable* x1 = new variable();
	variable* y1 = new variable();
	x->determine_value("3");
	y->determine_value("\"str\"");
	QVector<predicate> pred;
	QVector<variable*> vars;
	vars<<x<<y;
	result.set_name("animal");
	result.add_arguments(vars,0);
	temp1.set_name("parent");
	x1->determine_value("4.5");
	y1->determine_value("\'t\'");
	vars.clear();
	vars<<x1,y1;
	temp1.add_arguments(vars,0);
	pred<<temp1;
	result.add_usedpredicates(pred,0);
	QMap <QString, int> argsindexs;
	g.lex->next();
	g.analyse_clause();
	QVERIFY2(*(g.get_predicate(result.get_name())) == result,"test_analyse_clause_test5");

}

//Тест для примитивного правила, все аргументы - служебные символы
void parser_test::test_analyse_clause_test6()
{
	/*cpplexer* l = new cpplexer;
	l->createBufferFromString("animal(char, char)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("parent(char, char)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("animal('\\n', '\\\\'):-parent('r', 't').");
	g.lex = l;
	predicate result, temp1;
	temp1.add_predicate_description();
	result.add_predicate_description();
	variable x,y,x1,y1;
	x.determine_value("'\\n'");
	y.determine_value("'\\\\'");
	QVector<predicate> pred;
	QVector<variable> vars;
	vars<<x<<y;
	result.set_name("animal");
	result.add_arguments(vars,0);
	temp1.set_name("parent");
	x1.determine_value("'r'");
	y1.determine_value("'t'");
	vars.clear();
	vars<<x1<<y1;
	temp1.add_arguments(vars,0);
	pred<<temp1;
	result.add_usedpredicates(pred,0);
	QMap <QString, int> argsindexs;
	g.lex->next();
	g.analyse_clause();
	QVERIFY2(*(g.get_predicate(result.get_name())) == result,"test_analyse_clause_test6");*/
}

//Есть аргуенты со значением и без, соединены через ;
void parser_test::test_analyse_clause_test7()
{
	cpplexer* l = new cpplexer;
	l->createBufferFromString("mother(real, string)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("parent(char, integer)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("female(char)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("mother(4.8 , \"string\"):-parent('X', 3); female('X').");
	g.lex = l;
	predicate result, temp1,temp2;
	temp1.add_predicate_description();
	temp2.add_predicate_description();
	result.add_predicate_description();
	result.add_predicate_description();
	variable* x = new variable();
	variable* y = new variable();
	variable* x1 = new variable();
	variable* y1 = new variable();
	variable* x2 = new variable();
	x->determine_value("4.8");
	y->determine_value("\"string\"");
	QVector<predicate> pred;
	QVector<variable*> vars;
	vars<<x<<y;
	result.add_arguments(vars,0);
	result.add_arguments(vars,1);
	vars.clear();
	x1->determine_value("\'X\'");
	y1->determine_value("3");
	temp1.set_name("parent");
	vars<<x1<<y1;
	temp1.add_arguments(vars,0);
	vars.clear();
	x2->determine_value("\'X\'");
	vars<<x2;
	temp2.add_arguments(vars,0);
	temp2.set_name("female");
	pred<<temp1;
	result.set_name("mother");
	result.add_usedpredicates(pred,0);
	pred.clear();
	pred<<temp2;
	result.add_usedpredicates(pred,1);
	QMap <QString, int> argsindexs;
	g.lex->next();
	g.analyse_clause();
	QVERIFY2(*(g.get_predicate(result.get_name())) == result,"test_analyse_clause_test7");
}

//Тест для clause со значениями аргументов и без, соединены через ,
void parser_test::test_analyse_clause_test8()
{
	cpplexer* l = new cpplexer;
	l->createBufferFromString("mother(real)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("parent(char, integer)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("grandparent(real)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("mother(Y):-parent('r',5); grandparent(Y).");
	g.lex = l;
	predicate result, temp1,temp2;
	temp1.add_predicate_description();
	temp2.add_predicate_description();
	result.add_predicate_description();
	result.add_predicate_description();
	variable* x = new variable();
	variable* y = new variable();
	variable* y1 = new variable();
	y->set_value(NULL);
	y->set_vartype(Real);
	QVector<predicate> pred;
	QVector<variable*> vars;
	vars<<y;
	result.add_arguments(vars,0);
	result.add_arguments(vars,1);
	vars.clear();
	x->determine_value("'r'");
	y1->determine_value("5");
	temp1.set_name("parent");
	vars<<x<<y1;
	temp1.add_arguments(vars,0);
	x->set_value(NULL);
	vars.clear();
	vars<<y;
	temp2.add_arguments(vars,0);
	temp2.set_name("grandparent");
	pred<<temp1<<temp2;
	result.set_name("mother");
	result.add_usedpredicates(pred,0);
	QMap <QString, int> argsindexs;
	argsindexs.insert("Y",0);
	result.add_argindexs(argsindexs, 0);
	result.add_argindexs(argsindexs, 1);
	g.lex->next();
	g.analyse_clause();
	QVERIFY2(*(g.get_predicate(result.get_name())) == result,"test_analyse_clause_test8");
}

//тест, где предикаты соединены и через ; и через , у аргументов имеются значения
void parser_test::test_analyse_clause_test9()
{
	cpplexer* l = new cpplexer;
	l->createBufferFromString("animal(string,real)");
	parser g(l);
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("lion(integer,string)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("tiger(real)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("cat(char)");
	g.lex = l;
	g.lex->next();
	g.analyse_predicate();
	l->createBufferFromString("animal(X,Y):-lion(3,\"name\"),tiger(4.4);cat('S').");
	g.lex = l;
	predicate result, temp1,temp2, temp3;
	temp1.add_predicate_description();
	temp2.add_predicate_description();
	temp3.add_predicate_description();
	result.add_predicate_description();
	result.add_predicate_description();
	variable* x= new variable() ;
	variable* y= new variable() ;
	variable* x1= new variable();
	variable* y1= new variable();
	variable* z= new variable();
	variable* z1= new variable();
	x->set_value(NULL);
	y->set_value(NULL);
	x->set_vartype(String);
	y->set_vartype(Real);
	QVector<predicate> pred;
	QVector<variable*> vars;
	vars<<x<<y;
	result.add_arguments(vars,0);
	result.add_arguments(vars,1);
	vars.clear();
	x1->determine_value("3");
	y1->determine_value("\"name\"");
	temp1.set_name("lion");
	vars<<x1<<y1;
	temp1.add_arguments(vars,0);
	vars.clear();
	z->determine_value("4.4");
	temp2.set_name("tiger");
	vars<<z;
	temp2.add_arguments(vars,0);
	vars.clear();
	z1->determine_value("'S'");
	temp3.set_name("cat");
	vars<<z1;
	temp3.add_arguments(vars,0);
	pred<<temp1<<temp2;
	result.set_name("animal");
	result.add_usedpredicates(pred,0);
	pred.clear();
	pred<<temp3;
	result.add_usedpredicates(pred,1);
	QMap <QString, int> argsindexs;
	argsindexs.insert("X",0);
	argsindexs.insert("Y",1);
	result.add_argindexs(argsindexs, 0);
	result.add_argindexs(argsindexs, 1);
	g.lex->next();
	g.analyse_clause();
	QVERIFY2(*(g.get_predicate(result.get_name())) == result,"test_analyse_clause_test9");
}


void parser_test::test_analyse_predicate_block_exceptions_test1()
{
	cpplexer* l = new cpplexer;
	l->createBufferFromString("animal(string;real)\nlion(integer,string)\ntiger(integer,integer)");
	parser g(l);
	char exp_result[250];
	try
	{
		g.lex = l;
		g.analyse_predicate_block();
	}
	catch(char * result )
	{
		strcpy(exp_result,"Error in the description of the predicate block: Error in the description of the predicate: there is no separator between the types");
		QVERIFY2(strcmp(exp_result,result)==0,"Different errors in test_analyse_predicate_block_exceptions_test1 returned");
	}
}

void parser_test::test_analyse_predicate_block_exceptions_test2()
{
	cpplexer* l = new cpplexer;
	l->createBufferFromString("!animal(string;real)\nlion(integer,string)\ntiger(integer,integer)");
	parser g(l);
	char exp_result[250];
	try
	{
		g.lex = l;
		g.analyse_predicate_block();
	}
	catch(char * result )
	{
		strcpy(exp_result,"Error in the description of the predicate block: there are no predicate and name for the new block");
		QVERIFY2(strcmp(exp_result,result)==0,"Different errors in test_analyse_predicate_block_exceptions_test2 returned");
	}
}

void parser_test::test_analyse_predicate_block_exceptions_test3()
{
	cpplexer* l = new cpplexer;
	l->createBufferFromString("\"\"");
	parser g(l);
	char exp_result[250];
	try
	{
		g.lex = l;
		g.analyse_predicate_block();
	}
	catch(char * result )
	{
		strcpy(exp_result,"Error in the description of the predicate block: Invalid type of token");
		QVERIFY2(strcmp(exp_result,result)==0,"Different errors in test_analyse_predicate_block_exceptions_test2 returned");
	}
}

void parser_test::test_analyse_predicate_block_exceptions_test4()
{
	cpplexer* l = new cpplexer;
	l->createBufferFromString("animal(string,real)\n(integer,string)\ntiger(integer,integer)");
	parser g(l);
	char exp_result[250];
	try
	{
		g.lex = l;
		g.analyse_predicate_block();
	}
	catch(char * result )
	{
		strcpy(exp_result,"Error in the description of the predicate block: there is no name for the new block");
		QVERIFY2(strcmp(exp_result,result)==0,"Different errors in test_analyse_predicate_block_exceptions_test2 returned");
	}
}

void parser_test::test_analyse_predicate_block_exceptions_test5()
{
	cpplexer* l = new cpplexer;
	l->createBufferFromString("GOAL");
	parser g(l);
	char exp_result[250];
	try
	{
		g.lex = l;
		g.analyse_predicate_block();
	}
	catch(char * result )
	{
		strcpy(exp_result,"Error in the description of the predicate block: there is no name for the new block");
		QVERIFY2(strcmp(exp_result,result)==0,"Different errors in test_analyse_predicate_block_exceptions_test2 returned");
	}
}

void parser_test::test1()
{
	cpplexer* lex = new cpplexer;
	variable* input1 = new variable;
	input1->set_value(NULL);
	c_type* v = input1->get_value();
	lex->createBufferFromString("PREDICATES\nlikes(string, string)\nfruit(string)\ncolor(string, string)\nCLAUSES\nlikes(\"mary\", \"pears\").\nlikes(\"mary\", \"popcorn\").\nlikes(\"mary\", \"apples\").\nlikes(\"beth\", X):-likes(\"mary\", X), fruit(X), color(X, \"red\").\nfruit(\"pears\").\nfruit(\"apples\").\ncolor(\"pears\", \"yellow\").\ncolor(\"oranges\", \"orange\").\ncolor(\"apples\", \"red\").\ncolor(\"apples\", \"yellow\").\nGOAL\nlikes(\"beth\", X).");
	parser* par = new parser (lex);
	interpreter* inter = new interpreter(par);
	par->analyse_blocks();
	par->print("temp.txt");
	QString res = inter->get_result();
	QString exp_result = QString("X = \"apples\"\n");
	exp_result.remove(QChar('\\'));
	QVERIFY2(res==exp_result,"test1");
}

void parser_test::test2()
{
	cpplexer* lex = new cpplexer;
	variable* input1 = new variable;
	input1->set_value(NULL);
	c_type* v = input1->get_value();
	lex->createBufferFromString("PREDICATES\nlikes(string, string)\nfruit(string)\ncolor(string, string)\nCLAUSES\nlikes(\"mary\", \"pears\").\nlikes(\"mary\", \"popcorn\").\nlikes(\"mary\", \"apples\").\nlikes(\"beth\", X):-likes(\"mary\", X), fruit(X), color(X, \"red\").\nfruit(\"pears\").\nfruit(\"apples\").\ncolor(\"pears\", \"yellow\").\ncolor(\"oranges\", \"orange\").\ncolor(\"apples\", \"red\").\ncolor(\"apples\", \"yellow\").\nGOAL\nlikes(\"beth\", \"pears\").");
	parser* par = new parser (lex);
	interpreter* inter = new interpreter(par);
	par->analyse_blocks();
	par->print("temp.txt");
	QString res = inter->get_result();
	QVERIFY2(res == "no","test2");
}

void parser_test::test3()
{
	cpplexer* lex = new cpplexer;
	variable* input1 = new variable;
	input1->set_value(NULL);
	c_type* v = input1->get_value();
	lex->createBufferFromString("PREDICATES\nlikes(string, string)\nfruit(string)\ncolor(string, string)\nCLAUSES\nlikes(\"mary\", \"pears\").\nlikes(\"mary\", \"popcorn\").\nlikes(\"mary\", \"apples\").\nlikes(\"beth\", X):-likes(\"mary\", X), fruit(X), color(X, \"red\").\nfruit(\"pears\").\nfruit(\"apples\").\ncolor(\"pears\", \"yellow\").\ncolor(\"oranges\", \"orange\").\ncolor(\"apples\", \"red\").\ncolor(\"apples\", \"yellow\").\nGOAL\nlikes(\"beth\", \"apples\").");
	parser* par = new parser (lex);
	interpreter* inter = new interpreter(par);
	par->analyse_blocks();
	par->print("temp.txt");
	QString res = inter->get_result();
	QVERIFY2(res == "yes","test3");
}

void parser_test::test4()
{
	cpplexer* lex = new cpplexer;
	variable* input1 = new variable;
	input1->set_value(NULL);
	c_type* v = input1->get_value();
	lex->createBufferFromString("PREDICATES\nlikes(string, string)\nfruit(string)\ncolor(string, string)\nCLAUSES\nlikes(\"mary\", \"pears\").\nlikes(\"mary\", \"popcorn\").\nlikes(\"mary\", \"apples\").\nlikes(\"beth\", X):-likes(\"mary\", X), fruit(X).\nfruit(\"pears\").\nfruit(\"apples\").\ncolor(\"pears\", \"yellow\").\ncolor(\"oranges\", \"orange\").\ncolor(\"apples\", \"red\").\ncolor(\"apples\", \"yellow\").\nGOAL\nlikes(\"beth\", X), color(X, \"red\").");
	parser* par = new parser (lex);
	interpreter* inter = new interpreter(par);
	par->analyse_blocks();
	//par->print("temp.txt");
	QString res = inter->get_result(); // X = "apples"
	QString exp_result = QString("X = \"apples\"\n");
	exp_result.remove(QChar('\\'));
	QVERIFY2(res==exp_result,"test4");
}

void parser_test::test5()
{
        cpplexer* lex = new cpplexer;
        variable* input1 = new variable;
        input1->set_value(NULL);
        c_type* v = input1->get_value();
		lex->createBufferFromString("PREDICATES\nlikes(string, string)\nfruit(string)\ncolor(string, string)\nCLAUSES\nlikes(\"mary\", \"pears\").\nlikes(\"mary\", \"popcorn\").\nlikes(\"mary\", \"apples\").\nlikes(\"beth\", X):-likes(\"mary\", X), fruit(X), color(X, \"red\").\nfruit(\"pears\").\nfruit(\"apples\").\ncolor(\"pears\", \"yellow\").\ncolor(\"oranges\", \"orange\").\ncolor(\"apples\", \"red\").\ncolor(\"apples\", \"yellow\").\nGOAL\nlikes(\"beth\", X);color(X,\"blue\").");
        parser* par = new parser (lex);
        interpreter* inter = new interpreter(par);
        par->analyse_blocks();
        //par->print("temp.txt");
        QString res = inter->get_result(); // X = "apples"
		QString exp_result = QString("X = \"apples\"\n");
		exp_result.remove(QChar('\\'));
		QVERIFY2(res==exp_result,"test5");
}


void parser_test::test6()
{
	cpplexer* lex = new cpplexer;
	variable* input1 = new variable;
	input1->set_value(NULL);
	c_type* v = input1->get_value();
	lex->createBufferFromString("PREDICATES\nlikes(string, string)\nfruit(string)\ncolor(string, string)\nCLAUSES\nlikes(\"mary\", \"pears\").\nlikes(\"mary\", \"popcorn\").\nlikes(\"mary\", \"apples\").\nlikes(\"beth\", X):-likes(\"mary\", X), fruit(X), color(X, \"red\").\nfruit(\"pears\").\nfruit(\"apples\").\ncolor(\"pears\", \"yellow\").\ncolor(\"oranges\", \"orange\").\ncolor(\"apples\", \"red\").\ncolor(\"apples\", \"yellow\").\nGOAL\nlikes(\"catty\", X);color(X,\"red\").");
	parser* par = new parser (lex);
	interpreter* inter = new interpreter(par);
	par->analyse_blocks();
	//par->print("temp.txt");
	QString res = inter->get_result(); // X = "apples"
	QString exp_result = QString("X = \"apples\"\n");
	exp_result.remove(QChar('\\'));
	QVERIFY2(res==exp_result,"test6");
}

	/*
	Для кода вида 
PREEDICATES
likes(string,string)
CLAUSES
likes(ellen,tennis).
likes(john,football).
likes(tom,baseball).
likes(eric,swimming).
likes(mark,tennis).
GOAL likes(john,football).
	*/
void parser_test::test7()
{
	cpplexer* lex = new cpplexer;
	lex->createBufferFromString("PREDICATES\nlikes(string, string)\nCLAUSES\nlikes(\"ellen\",\"tennis\").\nlikes(\"john\",\"football\").\nlikes(\"tom\",\"baseball\").\nlikes(\"eric\",\"swimming\").\nlikes(\"mark\",\"tennis\").\nGOAL\nlikes(\"john\",\"football\").");
	parser* par = new parser (lex);
	interpreter* inter = new interpreter(par);
	par->print("temp.txt");
	par->analyse_blocks();
	QString res = inter->get_result();
	QVERIFY2(res == "yes","test7");
}
	/*
	Для кода вида 
PREDICATES
car( string, integer, string, integer ) 
CLAUSES
car( volvo, 1990, red, 1800 ).
car( toyota, 1988, black, 2000 ).
car( ford, 1994, white,    3000 ).
GOAL
car( mersedes, 1990, _ , _ ).
	*/
void parser_test::test8()
{
	cpplexer* lex = new cpplexer;
	lex->createBufferFromString("PREDICATES\ncar( string, integer, string, integer )\nCLAUSES\ncar( \"volvo\", 1990, \"red\", 1800 ).\ncar( \"toyota\", 1988, \"black\", 2000 ).\ncar( \"ford\", 1994, \"white\", 3000 ).\nGOAL\ncar( \"mersedes\", 1990, _ , _ ).");
	parser* par = new parser (lex);
	interpreter* inter = new interpreter(par);
	par->print("temp.txt");
	par->analyse_blocks();
	QString res = inter->get_result();
	QVERIFY2(res == "no","test8");
}
//
	/*
	Для кода вида 
PREDICATES
car( string, integer, string, integer ) 
CLAUSES
car( volvo, 1990, red, 1800 ).
car( toyota, 1988, black, 2000 ).
car( ford, 1994, white,    3000 ).
GOAL
car( X, _ , _ , _ ).
	*/
void parser_test::test9()
{
	cpplexer* lex = new cpplexer;
	lex->createBufferFromString("PREDICATES\ncar( string, integer, string, integer )\nCLAUSES\ncar( \"volvo\", 1990, \"red\", 1800 ).\ncar( \"toyota\", 1988, \"black\", 2000 ).\ncar( \"ford\", 1994, \"white\", 3000 ).\nGOAL\ncar( X, _ , _ , _ ).");
	parser* par = new parser (lex);
	interpreter* inter = new interpreter(par);
	par->print("temp.txt");
	par->analyse_blocks();
	QString res = inter->get_result();
	QString exp_result = QString("X = \"volvo\"\nX = \"toyota\"\nX = \"ford\"\n");
	exp_result.remove(QChar('\\'));
	QVERIFY2(res == exp_result, "test9");
}


/*
 	Для кода вида
 PREEDICATES
 likes(string,string) 
 game(string) 
 CLAUSES 
 likes(X,tennis):-game(Y).
 likes(john,football).
 likes(tom,baseball). 
 likes(eric,swimming).
 likes(mark,tennis).
 GOAL likes(Y,football). 
 	*/ 
 void parser_test::test10() 
 {
 	cpplexer* lex = new cpplexer; 
 	variable* input1 = new variable; 
 	input1->set_value(NULL); 
 	c_type* v = input1->get_value(); 
 	lex->createBufferFromString("PREDICATES\nlikes(string, string)\nname(string)\ngame(string)\nCLAUSES\nname(\"john\").\nname(\"tom\").\nname(\"eric\").\nname(\"mark\").\ngame(\"football\").\ngame(\"baseball\").\ngame(\"tennis\").\nlikes(X,Y):-name(X),game(Y).\nlikes(\"john\",\"football\").\nlikes(\"tom\",\"baseball\").\nlikes(\"eric\",\"swimming\").\nlikes(\"mark\",\"tennis\").\nGOAL\nlikes(Z,\"football\")."); 
 	parser* par = new parser (lex); 
 	interpreter* inter = new interpreter(par); 
 	par->analyse_blocks(); 
 	QString res = inter->get_result(); 
	QString exp_result = QString("Z = \"john\"\nZ = \"john\"\nZ = \"tom\"\nZ = \"eric\"\nZ = \"mark\"\n");
	exp_result.remove(QChar('\\'));
 	QVERIFY2(res == exp_result,"test10");
 }

 void parser_test::test11() 
 {
 	cpplexer* lex = new cpplexer; 
 	variable* input1 = new variable; 
 	input1->set_value(NULL); 
 	c_type* v = input1->get_value(); 
 	lex->createBufferFromString("PREDICATES\nlikes(string, string)\nname(string)\ngame(string)\nCLAUSES\nname(\"john\").\nname(\"tom\").\nname(\"eric\").\nname(\"mark\").\ngame(\"football\").\ngame(\"baseball\").\ngame(\"tennis\").\nlikes(\"john\",\"football\").\nlikes(\"tom\",\"baseball\").\nlikes(\"eric\",\"swimming\").\nlikes(\"mark\",\"tennis\").\nlikes(X,Y):-name(X),game(Y).\n\nGOAL\nlikes(Z,W)."); 
 	parser* par = new parser (lex); 
 	interpreter* inter = new interpreter(par); 
 	par->analyse_blocks(); 
 	QString res = inter->get_result(); 
	QString exp_result = QString("Z = \"john\", W = \"football\"\nZ = \"tom\", W = \"baseball\"\nZ = \"eric\", W = \"swimming\"\nZ = \"mark\", W = \"tennis\"\nZ = \"john\", W = \"football\"\nZ = \"john\", W = \"baseball\"\nZ = \"john\", W = \"tennis\"\nZ = \"tom\", W = \"football\"\nZ = \"tom\", W = \"baseball\"\nZ = \"tom\", W = \"tennis\"\nZ = \"eric\", W = \"football\"\nZ = \"eric\", W = \"baseball\"\nZ = \"eric\", W = \"tennis\"\nZ = \"mark\", W = \"football\"\nZ = \"mark\", W = \"baseball\"\nZ = \"mark\", W = \"tennis\"\n");
 	QVERIFY2(res == exp_result,"test11");
 } 

 void parser_test::test12() 
 {
 	cpplexer* lex = new cpplexer; 
 	variable* input1 = new variable; 
 	input1->set_value(NULL); 
 	c_type* v = input1->get_value(); 
 	lex->createBufferFromString("PREDICATES\nlikes(string, string)\nfruit(string)\ncolor(string, string)\nCLAUSES\nlikes(\"mary\", \"pears\").\nlikes(\"mary\", \"popcorn\").\nlikes(\"mary\", \"apples\").\nlikes(\"beth\", X):-likes(\"mary\", X), fruit(X), color(X, \"red\").\nfruit(\"pears\").\nfruit(\"apples\").\ncolor(\"pears\", \"yellow\").\ncolor(\"oranges\", \"orange\").\ncolor(\"apples\", \"red\").\ncolor(\"apples\", \"yellow\").\nGOAL\nlikes(Y, X)."); 
 	parser* par = new parser (lex); 
 	interpreter* inter = new interpreter(par); 
 	par->analyse_blocks(); 
 	QString res = inter->get_result(); 
	QString exp_result = QString("Y = \"mary\", X = \"pears\"\nY = \"mary\", X = \"popcorn\"\nY = \"mary\", X = \"apples\"\nY = \"beth\", X = \"apples\"\n");
 	QVERIFY2(res == exp_result,"test12");
 } 